<title>file upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php

// header("refresh:5 ; url=index.php")

// file path setup
$tmp_dir = "/tmp/";
$dist_dir = "/var/www/icas/";
$logfile = "/var/www/icas/";

// post value with upload file infomation
$userfile=$_FILES['userfile']['tmp_name'];
$userfile_name=$_FILES['userfile']['name'];
$userfile_size=$_FILES['userfile']['size'];
$userfile_type=$_FILES['userfile']['type'];
$userfile_error=$_FILES['userfile']['error'];


// log  title
$log_content = "
========= upload  log  file  ============= \n
start time : ".date('Y-m-d_G:i:s')." 
file name: $userfile_name
file size:  $userfile_size
file type : $userfile_type
file error : $userfile_error

";
// check if csr file is correct

if ($_FILES['userfile']['name']!='') {
   $uploaddir = '/home/waue/in/';
   //$uploaddir = '/home/waue/ICAS_workspace/in/';
   //   $uploaddir = './tmp/up';
   //$uploadfile = "$uploaddir"."/"."$userfile_name".".log";
   $uploadfile = "$uploaddir"."/".date("Ymd-His").".log";

   print "<pre>";
   if (move_uploaded_file($userfile, $uploadfile)) {
       echo "The file ".  basename( $_FILES['userfile']['name']).
            " has been uploaded";
       echo "\n and ICAS start ...";
       passthru('/home/waue/ICAS/bin/ICAS.sh');
   } else {
       print "Possible file upload attack!";
       print_r($userfile ."->". $uploadfile);
   }

print "</pre>";
}

function  log_echo( $str)
{
	global $log_content;
	$log_content .= "$str \n";
	echo "$str <br>";
}
function  log_only( $str)
{
	global $log_content;
	$log_content .= "$str \n";
}

?>
</br>
<p><a href=index.html>back to Main Page</a></p>

